package org.test.client.ui.skinui;

import java.awt.Color;

import javax.swing.PopupFactory;
import javax.swing.UIManager;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ColorUIResource;

import org.test.client.ui.skinui.btn.MyButtonUI;
import org.test.client.ui.skinui.checkbox.CheckBoxAndRadioUI;
import org.test.client.ui.skinui.ext.BESeparatorUI;
import org.test.client.ui.skinui.ext.ExtIconFactory;
import org.test.client.ui.skinui.other.BEDashedRoundRecBorder;
import org.test.client.ui.skinui.popup.TranslucentPopupFactory;
import org.test.client.ui.skinui.txtfield.MyTextFieldUI;


public class BEUIInstall {
	
	
	public static final Color commonBackgroundColor = new Color(250,250,250);;
	public static final Color commonForegroundColor = new Color(60,60,60);
	public static final Color commonFocusedBorderColor = new Color(162,162,162);
	public static final Color commonSelectionBackgroundColor = new Color(2,129,216);
	public static final Color commonSelectionForegroundColor = new Color(255,255,255);
	public static final Color commonDisabledForegroundColor = new Color(172,168,153);
	
	public static PopupFactory popupFactoryDIY = new TranslucentPopupFactory();

	public static void installUI(){
		UIManager.put("ButtonUI", MyButtonUI.class.getName());
		UIManager.put("ToggleButtonUI",MyButtonUI.class.getName());
		CheckBoxAndRadioUI.initUI();
		//txtfield
		UIManager.put("TextFieldUI",MyTextFieldUI.class.getName());
		//滚动轴
		org.test.client.ui.skinui.scrollpane.__UI__.uiImpl();
		//popup
		PopupFactory.setSharedInstance(popupFactoryDIY);
		//menu
		org.test.client.ui.skinui.menu.__UI__.uiImpl();
		//other
		installPorperties();
	}
	
	public static void installPorperties(){
		UIManager.put("control",new ColorUIResource(commonBackgroundColor));
		UIManager.put("Separator.foreground",new ColorUIResource(new Color(180,180,180)));
		UIManager.put("ToolTip.foreground",new ColorUIResource(commonForegroundColor));
		
		UIManager.put("Separator.background",new ColorUIResource(Color.white));
		UIManager.put("Panel.foreground",new ColorUIResource(commonForegroundColor));
		UIManager.put("Panel.background",new ColorUIResource(commonBackgroundColor));
		
		UIManager.put("Label.foreground",new ColorUIResource(commonForegroundColor));
		UIManager.put("Label.background",new ColorUIResource(commonBackgroundColor));

		UIManager.put("ColorChooser.foreground",new ColorUIResource(commonForegroundColor));
		UIManager.put("ColorChooser.background",new ColorUIResource(commonBackgroundColor));
		UIManager.put("ColorChooser.swatchesDefaultRecentColor",new ColorUIResource(commonBackgroundColor));
		
		UIManager.put("TitledBorder.titleColor",new ColorUIResource(new Color(58,135,173)));//TitleBorder的标题颜色
		//TitledBorder的默认border实现（windows LNF中默认是圆色灰色实线距形）
		UIManager.put("TitledBorder.border",new BorderUIResource(new BEDashedRoundRecBorder(commonFocusedBorderColor)));
		
//		UIManager.put("OptionPaneUI",org.jb2011.lnf.windows2.ch3.NLOptionPaneUI.class.getName());
		//** Ui里的实现逻辑：此属性为true时将导致JOptionPane里的各按钮按BasicOptionPaneUI里设定的Insets进行
		//** UI展现：当按钮数<=2时使用的Insets=new Instes(2,8,2,8)，否则使用new Instes(2,4,2,4)，
		//** 这样的逻辑下，BeautyEye L&F实现里会使得按钮高度缩小而不好看，所以要关闭此属性
		UIManager.put("OptionPane.setButtonMargin",false);
		UIManager.put("OptionPane.foreground",new ColorUIResource(commonForegroundColor));
		UIManager.put("OptionPane.background",new ColorUIResource(commonBackgroundColor));
		UIManager.put("OptionPane.questionIcon",ExtIconFactory.getInstance().getOptionPaneQUESTIONIcon());
		UIManager.put("OptionPane.warningIcon",ExtIconFactory.getInstance().getOptionPaneWARNIcon());
		UIManager.put("OptionPane.informationIcon",ExtIconFactory.getInstance().getOptionPaneINFOIcon());
		UIManager.put("OptionPane.errorIcon",ExtIconFactory.getInstance().getOptionPaneERRORIcon());
		
		UIManager.put("SeparatorUI",BESeparatorUI.class.getName());
	}
}
